$(function() {
    var grid = $('#gridBillUnit').datagrid({
		//title: "按开票单位汇总",
        //iconCls: 'icon-save',
        methord: 'post',
        url: '/Main/CountBillByUnit',
		queryParams: {
		businessid: $('#ID').val()},
        striped: true, //奇偶行是否区分
        columns: [[
					{ field: 'BillUnitName', title: '开票单位' },
                    { field: 'BillCount', title: '开票数量'},
                    { field: 'BillMoney', title: '开票金额'}
				]],

        rownumbers: true,
        fitColumns: true,
		onLoadError: function(data, status, error){
			if(data.status == "400")
				indexPage.reLogin();
		}
    });
	
	var grid2 = $('#gridBillOffice').datagrid({
		//title: "按开票单位汇总",
        //iconCls: 'icon-save',
        methord: 'post',
        url: '/Main/CountBillByOffice',
		queryParams: {
		businessid: $('#ID').val()},
        striped: true, //奇偶行是否区分
        columns: [[
					{ field: 'OfficeName', title: '部室名称' },
                    { field: 'MoneyWithBill', title: '已开票金额'},
                    { field: 'MoneyWithoutBill', title: '未开票金额'}
				]],

        rownumbers: true,
        fitColumns: true,
		onLoadError: function(data, status, error){
			if(data.status == "400")
				indexPage.reLogin();
		}
    });
});

var CountBill = {};

CountBill.BillUnitSearch = function(){
	var date1 = $("#bcuDate1").datebox('getValue');
	var date2 = $("#bcuDate2").datebox('getValue');
	$("#gridBillUnit").datagrid({ url: '/Main/CountBillByUnit', queryParams: { date1: date1, date2: date2} });
}

CountBill.BillOfficeSearch = function(){
	var date1 = $("#bcoDate1").datebox('getValue');
	var date2 = $("#bcoDate2").datebox('getValue');
	$("#gridBillOffice").datagrid({ url: '/Main/CountBillByOffice', queryParams: { date1: date1, date2: date2} });
}